﻿using System;
using System.Collections.Generic;
using Acr.UserDialogs;
using Cashbook.ViewModels;
using Xamarin.Forms;

namespace Cashbook.Views
{
    public partial class EditStatementPage : ContentPage
    {
		public EditStatementVM editStatementVM;

        public EditStatementPage(BillVM bill)
        {
            InitializeComponent();
			editStatementVM = new EditStatementVM(bill, this.Navigation, UserDialogs.Instance);
        }

		protected override void OnAppearing()
		{
			base.OnAppearing();

            if (editStatementVM.Statements.Count == 0 || editStatementVM.Bill == null)
				editStatementVM.LoadBillCommand.Execute(null);
			
			BindingContext = editStatementVM;
		}

		void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
		{
			if (e.Item == null) return;
			// do something with e.SelectedItem
			((ListView)sender).SelectedItem = null; // de-select the row
		}

	}
}
